 <template>
  <div class="header flex justify-center position-relative">
    <div class="head-title">古交市经济运行--智慧管理服务平台</div>
    <div class="position-absolute right-0 flex align-center mt-1">
      <div class="times mr-1">{{ currTime }}</div>
      <div class="days mr-1">
        <p>{{ dateFull }}</p>
        <p>{{ dateWeek }}</p>
      </div>
    </div>
    <div class="position-absolute title-class">{{ title }}</div>
  </div>
</template>
<script>
import { dateFormat, GetLunarDay, getWeekDay, dealWithTime } from "./date";

export default {
  name: "header",
  data() {
    return {
      dateFull: "",
      dateWeek: "",
      currTime: "",
      timer: null,
      title: "",
    };
  },
  mounted() {
    this.getDate();
    let self = this;
    // 定时刷新时间
    this.timer = setInterval(() => {
      self.currTime = dealWithTime(new Date());
      if (self.currTime == "00:00:00") {
        self.getDate();
      }
    }, 500);
    console.log(this.$route.path);
    if (this.$route.path == "/sale") {
      this.title = "企业类型";
    } else if (this.$route.path == "/company") {
      this.title = "企业详情";
    }  else if (this.$route.path == "/search") {
      this.title = "数据分析";
    } else if (this.$route.path == "/billingl"){
      this.title = "总中转量";
    } else if (this.$route.path == "/billing") {
      let title = this.$route.query.title
      if(title){
        this.title = title;
      } else {
        this.title = "开票明细";
      }
    } else if (this.$route.path == "/companyList") {
       let title = this.$route.query.title
      if(title){
        this.title = title;
      } else {
        this.title = "销售量";
      }
    } else if (this.$route.path == "/companysale") {
      this.title = "企业列表";
    } else if (this.$route.path == "/earlyWarning") {
      this.title = "预警分析";
    }else if (this.$route.path == "/companygslist") {
      this.title = "规上企业列表";
    }
  },
  methods: {
    getDate() {
      let date = new Date();
      let dateFull = dateFormat("YYYY-mm-dd", date);
      let dateRet = GetLunarDay(date).split(" ")[1];
      this.dateFull = dateFull + " " + dateRet;
      this.dateWeek = getWeekDay(date);
    },
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer);
      this.timer = null;
    }
  },
};
</script>
<style lang="stylus" scoped>
.title-class {
  bottom: 20px;
  font-size: 24px;
  font-family: PingFang SC;
  font-weight: 400;
  color: #39D6FE;
}

.header {
  width: 1920px;
  height: 117px;
  background: url('../assets/img/headerbg.png');
  background-size: 1920px 117px;

  .head-title {
    height: 37px;
    font-size: 40px;
    font-family: Hiragino Sans GB;
    font-weight: normal;
    color: #7EFAFC;
    margin-top: 10px;
  }

  .times {
    font-size: 30px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #39D6FE;
  }

  .days p {
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #39D6FE;
  }
}
</style>
